package com.wentjiang;


import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;

import java.io.File;
import java.io.IOException;

/**
 * Created by jiangwentao on 7/20/2016.
 */
public class CFGfactory {
    private static Configuration configuration;
    public CFGfactory(){

    }
    public static Configuration getInstance(){
        if (configuration==null){
            Configuration instance =  new Configuration(Configuration.VERSION_2_3_23);
            instance.setDefaultEncoding("UTF-8");
            instance.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
            try {
                //this path change to you resources absolute path
                instance.setDirectoryForTemplateLoading(new File("D:/wanmeiproject/freemarkerExample/src/resources"));
            } catch (IOException e) {
                e.printStackTrace();
            }
            configuration = instance;
            return instance;
        }else {
            return configuration;
        }
    }

}
